#员工操作行为记录
class EmployeeActionHx < ActiveRecord::Base
  belongs_to :employee
  belongs_to :department
  belongs_to :company
  belongs_to :role

  scope :paginate, lambda {  |employee_id,start,limit|
    if employee_id == nil
      includes([:company,:department,:employee,:role])
    else
      #where('employee_id = ?', employee_id).includes([:company,:department,:employee,:role]).limit(start..limit)
      where('employee_id = ?', employee_id).includes([:company,:department,:employee,:role]).limit(limit).offset(start).order("id DESC")
    end
  }

  scope :page_count, lambda {  |employee_id|
    where('employee_id = ?', employee_id).select(:id)

  }
end
